package com.aboo.frame.vo;

import com.aboo.frame.constant.ErrEnum;
import com.aboo.frame.constant.FlagEnum;
import org.apache.commons.lang3.time.DateFormatUtils;

import java.util.Date;

public class ReturnVO<T> {

    private String flag;
    private String timestamp;
    private String errCode;
    private String errMsg;
    private String extend;
    private T data;

    public ReturnVO() {
        super();
        this.flag = FlagEnum.SUCCESS.getValue();
        this.timestamp = DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss");
    }

    public ReturnVO(ErrEnum error) {
        super();

        if (error != null) {
            if (error == ErrEnum.ERR_000000) {
                this.flag = FlagEnum.SUCCESS.getValue();
            } else {
                this.flag = FlagEnum.FAILURE.getValue();
            }
        }
        this.timestamp = DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss");
        this.errCode = error.getValue();
        this.errMsg = error.getText();
    }

    public String getFlag() {
        return flag;
    }

    public void setFlag(String flag) {
        this.flag = flag;
    }

    public String getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(String timestamp) {
        this.timestamp = timestamp;
    }

    public String getErrCode() {
        return errCode;
    }

    public void setErrCode(String errCode) {
        this.errCode = errCode;
    }

    public String getErrMsg() {
        return errMsg;
    }

    public void setErrMsg(String errMsg) {
        this.errMsg = errMsg;
    }

    public String getExtend() {
        return extend;
    }

    public void setExtend(String extend) {
        this.extend = extend;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

}
